package edu.ctbu.ctbujsj.dao;

import edu.ctbu.ctbujsj.domain.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.sql.Timestamp;
import java.util.List;

public interface StudentRepository extends JpaRepository<Student,Integer> {
    public List<Student> findByTrueNameLike(String affixName);

    public List<Student>findByBirthdayBetween(Timestamp start,Timestamp end);

    @Query("select o from Student o where o.name=(select max(p.name)from Student p)")
    public List<Student>findByMaxName();

   // @Query("select o from Student o where o.trueName=:trueName and o.sex=:sex")
    //public List<Student>findByNameAndSex(@Param("trueName")String trueName,@Param("sex")long sex);

    @Query("select o from Student o where o.trueName=:trueName and o.sex=:sex")
    public List<Student>findByNameAndSex(@Param("trueName")String trueName,@Param("sex")long sex);
}
